<template>
	<view style="width: 100%;position: relative;">
		<view class="top" >
			<view></view>
			<view class="top1">个人中心</view>
			<view class="top2" @click="modify">编辑资料</view>
		</view>
		<view class="header" v-bind:class="{'status':isH5Plus}">
			<view class="userinfo">
				<view class="face">
					<view class="_image">
						<image :src="userinfo.ava" @click="previewImage(userinfo.ava)"></image>
						<view class="username">{{userinfo.username}}
						</view>
					</view>
					<view class="info">
						<view class="addr">
							{{userinfo.sex == "M" ? "男":"女"}} · 上海
						</view>
						<!-- 标签 -->
						<view class="tag">
							<view class="taglist" v-for="val in userinfo.userLabels">{{val}}</view>

						</view>

						<!-- vip -->
						<view class="vip" v-if="userinfo.userTitle==1">
							<image class="img" src="../../static/user-vipicon.png" mode=""></image>
							<view class="text">
								<view class="txt">
									VIP魅力女士
								</view>
								<view class="txt">
									有效期至{{userinfo.vipEndTime||'2021年6月1日'}}
								</view>
							</view>

						</view>
						<!-- 签名 -->
						<view class="sign">
							{{userinfo.introduction||'本宝宝暂时还没想到个性的签名'}}
						</view>
					</view>
				</view>

			</view>

			<!-- 	<view class="setting">
				<u-button v-if="userinfo.status == 0" type="success" shape="circle" size="mini" @click="qiandao">签到</u-button>
				<u-button v-if="userinfo.status == 1" type="primary" :disabled="true" shape="circle" size="mini">已签到</u-button>
			</view> -->

			<view class="fans">
				<view class="fan" @click="fans(0)">
					<view class="">
						{{userinfo.myLikeCount||0}}
					</view>
					我喜欢
				</view>
				<view class="fan" @click="fans(1)">
					<view class="">
						{{userinfo.likeMeCount||0}}
					</view>
					喜欢我

				</view>
				<!-- v-if="userinfo.sex == 'F'" -->
				<view class="fan" @click="fans(2)" >
					<view class="">
						{{userinfo.score||0}}
					</view>
					钱包
				</view>
				<view class="fan" @click="fans(3)">
					<view class="">
						{{userinfo.diamondNum||0}}
					</view>
					钻石
				</view>
			</view>
		</view>
		<view class="vip-kt" @click="Vip()">
			<view class="left">
				VIP
			</view>
			<view class="right">
				<view class="txt">
					尊享VIP免费特权
				</view>
				<view class="but">
					{{userinfo.isVip == 0 ? "立即开通" : "马上续费"}}
				</view>
			</view>
		</view>
		<view class="vip-kt" style="display: flex; justify-content: space-between;" v-if="userinfo.isVip == 1">
			<view>剩余vip解锁次数</view>
			<view>{{todayUnlockSurplus}}/10</view>
		</view>
		<view class="vip-kt" style="display: flex; justify-content: space-between;" v-if="userinfo.isVip == 1">
			<view>vip到期时间</view>
			<view>{{vipEndTime}}</view>
		</view>
		<view class="vip-kt" @click="Vip()" v-if="userinfo.isOnTerm == 1">
			<view class="left">
				新人VIP
			</view>
			<view class="right">
				<view class="txt">
					到期时间{{userinfo.regGiftEndtime}}
				</view>
				<view style="text-align: center;">
					<view>剩余次数</view>
					<view class="but">{{userinfo.regGiftNum}}/3</view>
				</view>
			</view>
		</view>
		<view class="call">
			<view class="left">
				<view class="text">
					邀请福利
					<text>邀请用户领会员</text>
				</view>
			</view>
			<view class="right">
				<view class="btn" @click="yaoqing">
					查看福利
				</view>
			</view>
		</view>
		<!-- <view class="orders">
			<view class="box">
				<view class="label" hover-class="hover" @click="modify">
					<view class="icon">
						<image src="../../static/xiaoyuan1.png"></image>
					</view>
					<view class="">
						编辑资料
					</view>
				</view>
				<view class="label" hover-class="hover" @click="quanzi(openid)">
					<view class="icon">
						<image src="../../static/xiaoyuan1.png"></image>
					</view>
					<view class="">
						我的动态
					</view>
				</view>
				<view class="label" hover-class="hover" @click="zuopin(openid)">
					<view class="icon">
						<image src="../../static/xiangce.png"></image>
					</view>
					<view class="">
						邀请好礼
					</view>
				</view>
				<view class="label" hover-class="hover" @click="info(openid)">
					<view class="icon">
						<image src="../../static/my2.png"></image>
					</view>
					<view class="">
						绑定公众号
					</view>
				</view>

			</view>

		</view> -->

		<view class="list">
			<view class="li" hover-class="hover" @click="good">
				<view class="icon">
					<image src="../../static/dianzan.png"></image>
				</view>
				<view class="text">我的动态</view>

			</view>
			

			<view class="li" hover-class="hover" @click="gz">
				<view class="icon">
					<image src="../../static/guanzhu.png" style="width: 70%;height: 70%;margin-left: 8rpx;margin-top: 5rpx;"></image>
				</view>
				<view class="text">客服助手</view>
				
			</view>
			
			<u-modal v-model="show1" :title-style="{color: 'red'}" title="客服">
				<view class="slot-text">
					请扫描二维码
				</view>
				<view class="slot-text">
					客服微信号：xiaohuikefu-01
				</view>
				<image class="slot-img" src="../../static/kefu.jpg" mode=""></image>
			</u-modal>
			
			<u-modal v-model="show" @confirm="confirm" ref="uModal" :async-close="true" :mask-close-able="true" title="问题反馈">
				<view class="slot-content">
					<rich-text :nodes="content"></rich-text>
				</view>
			</u-modal>
			
			
			<view class="li" hover-class="hover" @click="about">
				<view class="icon">
					<image src="../../static/guanyu.png"></image>
				</view>
				<view class="text">关于我们</view>
			</view>
			<view class="li" hover-class="hover" @click="logout">
				<view class="icon">
					<image src="../../static/guanyu.png"></image>
					<!-- <image src="../../static/logout.png"></image> -->
				</view>
				<view class="text">设置</view>
			
			</view>
			<!-- <view class="li" hover-class="hover" >
				
				<view style="text-align: center; width: 100%;" class="text">上海悦宁贸易有限公司</view>
			</view> -->
			
		</view>

	</view>
	</view>
</template>
<script>
	import * as api from '@/api/api.js'
	export default {
		data() {
			return {
				openid: '111',
				inverted: true,
				ava: null,
				username: null,
				gender: null,
				sex:null,
				userinfo: {
					username: '',
					ava: '../../static/xiaoyuan1.png',
					gender: '',
					integral: '',
					fans: '',
					follow: '',
					status: '',
					myLikeCount:'',
					likeMeCount:'',
					diamondNum:''
				},
				todayUnlockSurplus:'',
				vipEndTime:'',
				isH5Plus: "",
				show: false,
				show1: false,
			};
		},
		onLoad() {
			//加载
			this.init();
			
			//this.login();
		},
		onShow() {
			this.init();
		},
		methods: {
			//
			
			
			//跳转邀请
			yaoqing(){
				uni.navigateTo({
					url: '/pages/user/yaoqing'
				})
				api.request({
					url:'/p/user/userInof',
					method:'GET'
				}).then(res=>{
					console.log(res)
				})
				
				// api.request({
				// 	url: '/p/user/userInfo',
				// 	method: 'GET',
				// }).then(res => {
				// 	this.invitatioCode = res.data.invitatioCode
				// 	console.log(this.invitatioCode )
				// 	uni.showModal({
				// 	    title: this.invitatioCode,
				// 	    content: '每拉一新人注册，得3次免费解锁机会(24小时有效)',
				// 	    success: function (res) {
				// 	        if (res.confirm) {
				// 	            console.log('用户点击确定');
				// 	        } else if (res.cancel) {
				// 	            console.log('用户点击取消');
				// 	        }
				// 	    }
				// 	});

				// })
			},
			about() {
				uni.navigateTo({
					url: 'about'
				})
			},
			//签到
			qiandao() {
				if (this.userinfo.status == 0) {
					api.request({
						url: '/userInfo/qianDaoById',
						method: 'GET',
						data: {
							userId: this.openid
						},
					}).then(res => {
						if (res.data.data == 1) {
							this.$refs.uToast.show({
								title: '签到成功,积分+1',
								type: 'success'
							})
							this.init();
						} else if (res.data.data == 0) {
							this.$refs.uToast.show({
								title: '签到失败',
								type: 'error'
							})
						}
					})
				} else {
					this.$refs.uToast.show({
						title: '您今天已完成签到！',
						type: 'warning'
					})
				}
			},
			previewImage(photos) {
				let imgsArray = [];
				imgsArray[0] = photos;
				uni.previewImage({
					current: 0,
					urls: imgsArray
				});
			},
			fans(res) {
				if(res==0){
					uni.switchTab({
						url: '/pages/message/message?current=' + res
					})
				}
				if(res==1){
					uni.switchTab({
						url: '/pages/message/message?current=' + res
					})
				}
				if (res == 2) {
					uni.navigateTo({
						url: '/pages/wallet/wallet?current=' + res +'&sex=' + this.sex
					})
				}
				if (res == 3) {
					uni.navigateTo({
						url: '/pages/pay/pay'
					})
				} else {
					// uni.navigateTo({
					// 	url: 'fans?current=' + res
					// })
				}

			},

			modify() {
				uni.navigateTo({
					url: 'modify/modify'
				})
			},
			good() {
				uni.navigateTo({
					url: '../good/mine'
				})
			},
			//信息初始化
			init() {
				api.request({
					url: '/p/user/userInfo',
					method: 'GET',
				}).then(res => {
					console.log(res.data)
					this.userinfo.ava = res.data.pic
					this.userinfo.username = res.data.nickName;
					this.userinfo.likeMeCount = res.data.likeMeCount;
					this.userinfo.myLikeCount = res.data.myLikeCount;
					this.userinfo.diamondNum = res.data.diamondNum;
					this.userinfo.sex = res.data.sex;
					this.userinfo.isVip = res.data.isVip;
					this.userinfo.regGiftNum = res.data.regGiftNum
					this.userinfo.regGiftEndtime = res.data.regGiftEndtime
					this.todayUnlockSurplus = res.data.todayUnlockSurplus;
					this.vipEndTime = res.data.vipEndTime
					this.userinfo.isOnTerm = res.data.isOnTerm
					console.log(this.userinfo)
					// if (res.data.userLabels == null) {
					// 	console.log("空");
					// } else {
					// 	res.data.userLabels = res.data.userLabels.split(',')
					// }
					// if (res.data.sex == 'M'){
					// 	this.sex=0
					// 	console.log(this.sex)
					// }else{
					// 	this.sex=1
					// 	console.log(this.sex)
					// }
					// this.userinfo = res.data
					// console.log(this.userinfo);
				})

			},
			quanzi(res) {
				uni.navigateTo({
					
					url: '../quanzi/mine?id=' + res
				})
			},
			gz(){
				this.show1 = true;
			},
			
			confirm() {
				setTimeout(() => {
					// 3秒后自动关闭
					this.show = false;
					// 如果不想关闭，而单是清除loading状态，需要通过ref手动调用方法
					// this.$refs.uModal.clearLoading();
				}, 500)
			},
			Vip(res) {
				uni.navigateTo({
					url: '/pages/vip/vip?vip=' + this.userinfo.isVip
				})
				
			},
			info(res) {
				// uni.navigateTo({
				// 	url: 'userinfo/userinfo?uid=' + res
				// })
			},
			modify() {
				uni.navigateTo({
					url: 'modify/modify'
				})
			},

			logout() {
				uni.navigateTo({
					url: 'shezhi'
				})
			
			},
			login() {
				var that = this;
				uni.getStorage({
					key: 'userInfo',
					success: function(res) {
						console.log(res.data);
						that.userinfo.username = res.data.username;
						that.userinfo.ava = res.data.avatarUrl;
						that.userinfo.gender = res.data.gender;
					},
					fail: function() {
						uni.navigateTo({
							url: 'login'
						})
					}
				});
			}

		}
	}
</script>

<style lang="scss">
	page {
		background-color: #242329
	}
	
	.top{
		width: 100%;
		height: 110rpx;
		margin-top: 30rpx;
		position: fixed;
		top: 0rpx;
		display: flex;
		justify-content: space-around;
		line-height: 110rpx;
		text-align: center;
		// background-color: #000000;
		z-index: 30;
		
		view {
			width: 25%;
		}
		
		.top1 {
			font-size: 34rpx;
			font-weight: 600;
			color: #FFA800;
		}
		
		.top2 {
			height: 80rpx;
			line-height: 80rpx;
			border-radius: 80rpx;
			background: #FFA800;
			margin-top: 30rpx;
		}
		
	}
	
	.vip-kt {
		width: 90%;
		margin: auto;
		padding: 30rpx 20rpx;
		margin-top: 30rpx;
		display: flex;
		color: #feb242;
		justify-content: space-between;
		border: 2rpx solid #feb242;
		border-radius: 15rpx;
		line-height:60rpx;
		.left {
		}
		.right {
			display: flex;
			.txt {
				font-size: 30rpx;
				margin-right: 10rpx;
			}
			.but {
				width: 150rpx;
				height: 60rpx;
				border-radius: 30rpx;
				background-color: #feb242;
				color: #3b3b43;
				text-align: center;
			}
		}
	}
	
	.slot-content {
		height: 160rpx;
		font-size: 36rpx;
		color: $u-content-color;
		padding-left: 30rpx;
		line-height: 60rpx;
		padding-top: 20rpx;
		text-align: center;
	}
	
	.slot-text {
		text-align: center;
		margin-top: 20rpx;
		margin-bottom: 20rpx;
	}
	
	.slot-img {
		width: 300rpx;
		height: 300rpx;
		display: flex;
		margin-left: 150rpx;
		padding-bottom: 30rpx;
	}
	
	.call{
		width: 90%;
		margin: auto;
		padding: 20rpx 20rpx;
		border-radius: 15rpx;
		margin-top: 20rpx;
		display: flex;
		color: #3b3b43;
		justify-content: space-between;
		background: linear-gradient(to left, rgba(255, 136, 0, .3), #F80);
		.text{
				line-height: 50rpx;
				text{
					
					font-size: 30rpx;
					margin-left: 20rpx;
				}
		}
		.btn{
			width: 150rpx;
			height: 50rpx;
			line-height: 50rpx;
			border-radius: 25rpx;
			background-color: #feb242;;
			color: #3b3b43;
			text-align: center;
			font-size: 30rpx;
			}
	}
	.code {
		width: 80%;
		margin: auto;
		display: flex;
		justify-content: space-between;
		line-height: 50upx;
		color: #feb242;
		margin-top: 50rpx;

		.num {
			display: flex;
			line-height: 50upx;
		}

		.code-icon {
			margin-left: 10upx;

			.img {
				width: 50upx;
				height: 50upx;
			}
		}
	}

	.header {
		&.status {
			padding-top: var(--status-bar-height);
		}

		position: relative;
		//background-image: linear-gradient(to top right, #f7797d, #fbd786);
		width:100%;
		height:45vw;
		//padding:0 4%;
		display:flex;
		margin-top: 138rpx;

		.userinfo {
			//width: 100%;
			display: flex;

			.face {
				display: flex;
				flex-shrink: 0;
				width: 100%;
				height: 25vw;
				margin-left: 30upx;

				._image {
					width: 25vw;
					height: 25vw;

					image {
						width: 100%;
						height: 100%;
						border-radius: 100%
					}
				}


				.username {
					color: #fff;
					font-size: 40upx;
					width: 340rpx;
				}
			}

			.info {
				flex-flow: wrap;
				padding-left: 30upx;

				.addr {
					height: 80upx;
					color: #949494;
					line-height: 80upx;
				}

				.sign {
					color: #949494;
					margin-top: 20upx;
				}

				.vip {
					float: right;
					display: flex;
					color: #fff;
					font-size: 24upx;
					margin-top: 10upx;

					.img {
						width: 60upx;
						height: 60upx;
						margin-right: 10upx;
					}
				}

				.tag {
					display: flex;
					flex-flow: wrap;

					.taglist {
						width: 60px;
						height: 20px;
						line-height: 20px;
						border-radius: 5px;
						color: #feb242;
						font-size: 14px;
						text-align: center;
						font-family: Arial;
						background-color: #211c20;
						margin-right: 20upx;
					}
				}

				.username {
					width: 100%;
					color: #fff;
					font-size: 40upx
				}

				.integral {
					display: flex;
					align-items: center;
					padding: 0 20upx;
					height: 40upx;
					color: #fff;
					background-color: rgba(0, 0, 0, 0.1);
					border-radius: 20upx;
					font-size: 24upx
				}
			}
		}

		.setting {
			flex-shrink: 0;
			width: 17vw;
			height: 10vw;
			position: absolute;
			right: 70rpx;
			top: 65rpx;


			image {
				width: 100%;
				height: 100%
			}
		}

		.fans {
			position: absolute;
			display: flex;
			width: 100%;
			bottom: 0rpx;

			.fan {
				flex: auto;
				height: 100%;
				text-align: center;
				color: #feb242;
				font-size: 30rpx;
			}
		}
	}

	.hover {
		background-color: #eee
	}

	.orders {
		width: 100%;
		height: 9vw;
		padding: 0 4%;
		margin-bottom: calc(11vw + 40upx);
		align-items: flex-start;
		border-radius: 0 0 100% 100%;
		margin-top: -1upx;

		.box {
			width: 100%;
			padding: 0 1%;
			height: 22vw;
			background-color: #fefefe;
			border-radius: 24upx;
			box-shadow: 0 0 20upx rgba(0, 0, 0, 0.15);
			margin-bottom: 10upx;
			display: flex;
			align-items: center;
			justify-content: center;
			text-align: center;

			.label {
				align-items: center;
				width: 100%;
				height: 16vw;
				color: #666666;
				font-size: 26upx;

				.icon {
					position: relative;
					width: 7vw;
					height: 7vw;
					margin: 10rpx auto;

					.badge {
						position: absolute;
						width: 4vw;
						height: 4vw;
						background-color: #ec6d2c;
						top: -1vw;
						right: -1vw;
						border-radius: 100%;
						font-size: 20upx;
						color: #fff;
						display: flex;
						align-items: center;
						justify-content: center;
						z-index: 10;
					}

					image {
						width: 7vw;
						height: 7vw;
						z-index: 9;
					}
				}
			}
		}
	}



	.list {
		width: 100%;
		margin-top: 20rpx;
		padding-bottom: 100rpx;
		.li {
			width: 100%;
			height: 100upx;
			padding: 0 4%;
			display: flex;
			align-items: center;

			&.noborder {
				border-bottom: 0
			}

			.icon {
				flex-shrink: 0;
				width: 50upx;
				height: 50upx;

				image {
					width: 50upx;
					height: 50upx
				}
			}

			.text {
				padding-left: 20upx;
				width: 100%;
				color: #feb242
			}

			.to {
				flex-shrink: 0;
				width: 40upx;
				height: 40upx
			}
		}
	}

	.comment {
		margin-top: 15rpx;
		display: flex;
		border-radius: 20rpx;
		//padding: 30rpx;
		//margin-top: 10rpx;
		margin-bottom: 20rpx;
		margin-left: 15rpx;
		margin-right: 15rpx;

		.grid-text {
			font-size: 28rpx;
			margin-top: 4rpx;
			color: $u-type-info;
		}

		.pic {
			.img_wrapper {
				width: 220upx;
				height: 150upx;
				margin-right: 15upx;
				display: inline-block;

				image {
					width: 100%;
					height: 100%;
				}
			}
		}

		.left {
			image {
				width: 64rpx;
				height: 64rpx;
				border-radius: 50%;
				background-color: #f2f2f2;
			}
		}

		.right {
			flex: 1;
			//padding-left: 20rpx;
			font-size: 30rpx;

			.gd {

				.image {
					margin-left: 20rpx;
				}
			}

			.top {
				display: flex;
				justify-content: space-between;
				align-items: center;
				margin-bottom: 10rpx;

				.name {
					position: absolute;
					left: 110rpx;

				}

				.like {
					display: flex;
					align-items: center;
					color: #9a9a9a;
					font-size: 26rpx;

					.num {
						margin-right: 4rpx;
						color: #9a9a9a;
					}
				}

				.highlight {
					color: #5677fc;

					.num {
						color: #5677fc;
					}
				}
			}

			.content {
				//margin-bottom: 10rpx;
				margin-left: 20rpx;
				margin-top: 15rpx;
				margin-bottom: 15rpx;
				margin-right: 20rpx;
			}

			.reply-box {
				//background-color: rgb(242, 242, 242);
				//border-radius: 12rpx;

				.item {
					padding: 20rpx;
					border-bottom: solid 2rpx $u-border-color;

					.username {
						
						font-size: 24rpx;
						color: #999999;
					}
				}

				.all-reply {
					padding: 20rpx;
					display: flex;
					color: #5677fc;
					align-items: center;

					.more {
						margin-left: 6rpx;
					}
				}
			}

			.test {
				float: left;
				padding: 15rpx;
			}

			.img {
				display: flex;
			}

			.bottom {
				//margin-top: 20rpx;
				// margin-left: 10rpx;
				// display: flex;
				// font-size: 24rpx;
				// color: #9a9a9a;
				// margin-bottom: 10rpx;

				.reply {
					color: #5677fc;
					margin-left: 10rpx;
				}

				.weibo-handle {
					display: flex;
					//padding-top: 15rpx;
					font-size: 28rpx;
					padding-bottom: 25rpx;
				}

				.weibo-handle image {
					width: 50rpx;
					height: 50rpx;
					margin-right: 20rpx;
				}

				.weibo-handle view {
					flex: 1;
					display: flex;
					justify-content: center;
					align-items: center;
				}

				.weibo-handle .comment-group {
					background: #ffffff;
				}

				.weibo-handle .praise-group {
					background: #ffffff;
				}

				// .weibo-handle .favor{
				// 	background: #ffffff;
				// }
			}
		}
	}
</style>
